// pagesLuxian/pages/loading/index.js
const app = getApp();
import { generateRoute, peopleGenerate_Stat } from "../../../api/luxian";

Page({
    data: {
        navData: {
            title: '智能路线生成中',
            level: 2,
        },
        form: {},
        wayData: null,
    },
    onLoad(options) {
        if (JSON.stringify(options) !== "{}") {
            this.data.form = JSON.parse(decodeURI(options.form))
            this.getTravel()
        } else {
            wx.showToast({
                icon: 'none',
                title: '页面参数获取失败',
                duration: 2000
            });
        };
    },
    getTravel() {
        // let form = JSON.parse(JSON.stringify(this.data.form));
        // let query = 'cfd=' + form.startPosition + '&mdd=' + form.endPosition + '&cxfs=' + form.travelMode + '&ywlx=' + form.villageValue + '&cxsj=' + form.startTime + '&jssj=' + form.endTime
        // this.setData({ loadQuery: query });
        this.setData({ wayData: encodeURIComponent(JSON.stringify(this.data.form)) })
        console.log(this.data.wayData)
        return false;

        generateRoute(this.data.form).then(res => {
            if (res.data.code === 200) {
                console.log(res)
                this.setData({ quesStr: encodeURIComponent(JSON.stringify(res.data.data)) })
                console.log(this.data.quesStr)
                // wx.navigateTo({
                //     url: '/pagesLuxian/pages/guihuaComplete/index?data=' + encodeURIComponent(JSON.stringify(this.data.form)) + '&id=' + res.data.data + '&ident=sc',
                // });
            } else {
                wx.showModal({
                    content: res.data.msg,
                    confirmColor: '#4646A0',
                    showCancel: false,
                    success(res) {
                        wx.navigateBack()
                    }
                });
            };

        });
    },
})